
#ifndef __GAME_H
#define __GAME_H

#define board_row 40
#define board_colum 40

/*头文件包含*/
#include <pthread.h>
#include <stdlib.h>
#include<stdio.h>
#include<time.h>
#include"list.h"
#include"touch_api.h"
#include"lcd_display_api.h"
#include"playmusic_api.h"
#include"font.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h> /* superset of previous */
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/mman.h>
#include <signal.h>
#include "debug.h"


/*全局变量声明*/
int snakeDir;

int degree;

int (*pic_arr)[12*12];

int gameOver;
int exitgame;


int socketFd;
int udp_socketFd;

struct sockaddr_in serverAddr;

struct sockaddr_in udp_serverAddr;



/*贪吃蛇游戏*/

/*宏定义*/
#define UNIT_SIZE 12

#define SERVER_PORT 13131
#define SERVER_ADDR "192.168.63.210" //120.77.239.140
//#define SERVER_ADDR "120.77.239.140" //阿里云

/*枚举*/

//游戏图片数据密钥下标
enum{
    snake_head_up = 0,
    snake_head_down,
    snake_head_left,
    snake_head_right,
    snake_body,
    food,
    snake_tail_up,
    snake_tail_down,
    snake_tail_left,
    snake_tail_right,
    snake_tail_second_up,
    snake_tail_second_down,
    snake_tail_second_left,
    snake_tail_second_right,
    mapColorOne,
    mapColorTwo,
    mapColorThree,
    mapColorFour
}pic_name;

enum {
    UP = 1,
    DOWN,
    LEFT,
    RIGHT
}SNAKEDIR;

enum {
    EASY = 0,
    MID,
    DIFFICULT
}SNAKE_DEGREE;

enum {
    START_GAME = 1,
    DATA_ERROR,
    EXIT_GAME,
}COMMAND;

/*结构体定义*/
typedef struct 
{
    int playerNum;
    int score;
    int gameDegree;
}playerInfo;

typedef struct 
{
    int sleepTime;
    int originalReward;
    int originalSnakeSpeed;
    int event;
}toolsData;

typedef struct 
{
    char map_arr[40][40];
    unsigned char score;
    char command;
    unsigned char mvp;
}tcp_server_data;

typedef struct
{
    int command; //枚举COMMAND可选
    int direc;   //枚举SNAKEDIR可选
}tcp_client_data;



/*函数声明*/

//gameDisplay.c
/*游戏画面显示线程*/
void game_display();
void* tcp_recv(void* arg);

//snake.c
/*线程取消例程函数*/
//void unLockSimple(void* arg);
/*贪吃蛇主函数*/



void* tcp_send(void* arg);


#endif